package com.sky.mapper;

import com.github.pagehelper.Page;
import com.sky.dto.GoodsSalesDTO;
import com.sky.dto.OrdersPageQueryDTO;
import com.sky.entity.Orders;
import com.sky.vo.OrderStatisticsVO;
import com.sky.vo.OrderVO;
import io.swagger.models.auth.In;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

import java.time.LocalDate;
import java.time.LocalDateTime;
import java.util.List;
import java.util.Map;

@Mapper
public interface OrderMapper {
    void insert(Orders orders);

    /**
     * 根据订单号查询订单
     * @param orderNumber
     */
    @Select("select * from orders where number = #{orderNumber} and user_id=#{userId}")
    Orders getByNumber(String orderNumber,Long userId);

    /**
     * 修改订单信息
     * @param orders
     */
    void update(Orders orders);

    Page<OrderVO> pageQuery(OrdersPageQueryDTO ordersPageQueryDTO);

    OrderVO getById(Long id);

    OrderStatisticsVO statistics();

    /**
     * 查询未支付的订单
     * @param
     * @param minusMinutes
     * @return
     */
    List<Orders> getByStatusAndOrderTimeLT(Integer status, LocalDateTime minusMinutes);

    /**
     * 根据状态统计营业额
     * @param map
     * @return
     */
    Double sumByMap(Map map);

    Integer countUserByDate(LocalDateTime endTime);

    Integer countNewUserByDate(LocalDateTime beginTime, LocalDateTime endTime);

    Integer count(LocalDateTime beginTime, LocalDateTime endTime, Integer status);

    List<GoodsSalesDTO> getSalesTop10(LocalDateTime beginTime, LocalDateTime endTime);
}
